﻿using UnityEngine;
using System.Collections;

public class GridCell : MonoBehaviour {
	public Vector2 boardPosition;
	public bool walkable;
	public int gValue;
	public int hValue;
	public int fValue;
	public GridCell parentGridCell;


	public Transform prefab;
	// Use this for initialization
	void Start () {
		/*if(!walkable)
			GameController.gc.navBoard[(int) boardPosition.y,(int) boardPosition.x] = 1;
		else
			GameController.gc.navBoard[(int) boardPosition.y,(int) boardPosition.x] = 0;
			*/
		fValue = 9001;
		walkable = true;
	}
	
	// Update is called once per frame
	void Update () {

	}

	void OnMouseDown(){
		Debug.Log ("clicked on a grid cell");
		GameController.gc.setPlayerTarget(boardPosition, this);
	}

	void OnMouseOver(){
		if (Input.GetMouseButtonDown(1)) {
			Instantiate(prefab, transform.position, Quaternion.identity);
			walkable = false;
		}
	}
	//constructor
	public GridCell(){

	}

	public static bool areEqual(GridCell node1, GridCell node2){
		if(node1 == null || node2 == null)
			return false;
		if(node1.boardPosition.x==node2.boardPosition.x && node1.boardPosition.y==node2.boardPosition.y){
			return true;
		}
		return false;
	}
}
